<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<head>
    <title>Client: Search</title>
</head>

<body>

    <form:form action="${pageContext.request.contextPath}/domain/client/search" modelAttribute="clientSearchForm" method="POST">

        <table class="show">
            <tbody>
                <tr>

                    <td>Client No:</td>
                    <td>
                        <form:input htmlEscape="true" path="clientid"/>
                        <form:errors htmlEscape="true" path="clientid" cssClass="error"/>
                    </td>

                    <td>First Name:</td>
                    <td>
                        <form:input htmlEscape="true" path="firstname"/>
                        <form:errors htmlEscape="true" path="firstname" cssClass="error"/>
                    </td>

                    <td>Last Name:</td>
                    <td>
                        <form:input htmlEscape="true" path="surname"/>
                        <form:errors htmlEscape="true" path="surname" cssClass="error"/>
                    </td>                                        

                </tr>
                <tr>
                    <td>Birthdate:<fmt:message key="date.default.format" /></td>
                    <td>
                        <form:input htmlEscape="true" path="dob"/>
                        <form:errors htmlEscape="true" path="dob" cssClass="error"/>
                    </td>
                    
                    <td>ID No:</td>
                    <td>
                        <form:input htmlEscape="true" path="idno"/>
                        <form:errors htmlEscape="true" path="idno" cssClass="error"/>
                    </td>
                    
                    <td>Status:</td>
                    <td>
                        <form:select htmlEscape="true" path="status" style="min-width:150px;">
                            <form:option htmlEscape="true" value="A">Active</form:option>
                            <form:option htmlEscape="true" value="I">Inactive</form:option>
                        </form:select>
                        <form:errors htmlEscape="true" path="status" cssClass="error"/>
                    </td>



                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="1" style="padding-top:20px;">
                        <input type="submit" class="button button-search" value="<fmt:message key="crud.search.button" />"/>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>
    <div id="result" />
    <br/>

    
        <c:if test="${clientCount == 0}">
            <form:errors cssClass="error"/>
        </c:if>    
        <table class="show">
            <tbody>
                <tr>
                    <th>Count.</th>
                    <th>Client No</th>
                    <th>Firstname</th>                    
                    <th>Surname</th>
                    <th>Birthdate</th>
                    <th>Status</th>
                    
                </tr>
                <c:forEach items="${clientForm.clientList}" var="client" varStatus="_status">
                    
                    <tr>
                        
                        <td>${_status.count}</td>
                        <td><a href="${pageContext.request.contextPath}/domain/client/displayClientProfile?'<c:out value="${client.clientid}"/>'" ><c:out value="${client.clientid}"/></a>
                        <td><input readonly="true" name="clientList[${_status.index}].firstname" value='<c:out value="${client.firstname}"/>'/></td>
                        <td><input readonly="true" name="clientList[${_status.index}].surname" value='<c:out value="${client.surname}"/>'/></td>
                        <td><input readonly="true" name="clientList[${_status.index}].dob" value='<c:out value="${client.dob}"/>'/></td>
                        <td><input readonly="true" name="clientList[${_status.index}].statusFormatted" value='<c:out value="${client.statusFormatted}"/>'/> </td>
                    </tr>
                </c:forEach>

            </tbody> 
            <tfoot>
                <tr>
                    <td colspan="2" style="padding-top:20px;">
                        <c:choose>
                            <c:when test="${clientCount == 0}">
                                <fmt:message key="crud.search.empty.result" />
                            </c:when>
                        </c:choose>
                    </td>
                </tr>
            </tfoot>

        </table>


</body>

